/**
 * Mark Fedor
 * Tony Greseth
 * CS 5551 User Interface Design
 * Section 1
 * Sai Chittilla
 * Yahtzee Program
 */

package Yahtzee;

import java.io.*;

/**
 * Class which holds of the high score information required to make
 * the top 10 list on the GUI
 */
public class HighScores implements Serializable {
    /**
     * Basic Constructor
     */
    public HighScores()
    {
        scores = new int[10];
        names = new String[10];
    }

    public HighScores(int score, String name, int position)
    {
        scores[position] = score;
        names[position] = name;
    }

    /**
     * adds the score to the list
     * @param score the score wanting to be added
     * @param name the name wanting to be added
     */
    public void addScore(int score, String name)
    {        
        for (int i = 0; i < 10; i++)
        {
            // check if the score is higher
            if (score >= scores[i])
            {
                // runs through the for loop which will go from the lowest score up
                for (int j = 9; j > i; j--)
                {
                    scores[j] = scores[j-1];
                    names[j] = names[j-1];
                }
                scores[i] = score;
                names[i] = name;
                // set i to 11 so that it won't overwrite crap
                i = 11;
            }
            
        }
    }
    /**
     * returns the score array
     * @return
     */
    public int[] getScores()
    {
        return scores;
    }

    /**
     * returns the names array
     * @return
     */
    public String[] getNames()
    {
        return names;
    }

    private int[] scores;
    private String[] names;
    private int entries = 0;



}
